/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-04-27
 * Time:21:19
 */

/**
 * Jz28 对称的二叉树
 */

public class isSymmetrical {
    public static boolean isSymmetrical(TreeNode pRoot) {
        return recur(pRoot,pRoot);
    }

    private static boolean recur(TreeNode pRoot1, TreeNode pRoot2) {
        if (pRoot1 == null && pRoot2 == null){
            return true;
        }
        if (pRoot1 == null || pRoot2 == null || pRoot2.val != pRoot1.val){
            return false;
        }
        return recur(pRoot1.left,pRoot2.right) && recur(pRoot1.right,pRoot2.left);
    }
}
